import requests
from config import url, headers_web

class CourseStatistics:

    def __int__(self):
        self.url = url
        self.headers = headers_web

    @classmethod
    def statistics_knowledge(cls, url: str, params=None,headers=headers_web):
        '''
        @Summary:统计指定版本下知识点数量
        @Description:1.云课堂：课程画像-课程整体数据使用
        :param url:
        :param params:
        :return:
        '''
        url = url + "/courseApi/api/v1/course/statistics/knowledge"
        r = requests.get(url=url, headers=headers, params=params)
        return r

    @classmethod
    def statistics_teachresource(cls, url: str, params=None,headers=headers_web):
        '''
        @Summary:统计课程下老师上传的资源以及使用次数
        @Description:1.云课堂：课程画像-课程整体数据使用
        :param url:
        :param params:
        :return:
        '''
        url = url + "/courseApi/api/v1/course/statistics/teachresource"
        r = requests.get(url=url, headers=headers, params=params)
        return r

    @classmethod
    def statistics_teachresourcenum(cls, url: str, params=None,headers=headers_web):
        '''
        @Summary:统计指定版本下资源占比以及数量
        @Description:1.云课堂：课程画像-课程整体数据使用
        :param url:
        :param params:
        :return:
        '''
        url = url + "/courseApi/api/v1/course/statistics/teachresource"
        r = requests.get(url=url, headers=headers, params=params)
        return r

    @classmethod
    def statistics_version(cls, url: str, params=None,headers=headers_web):
        '''
        @Summary:课程版本统计
        @Description:云课堂：课程画像-课程整体数据使用
        :param url:
        :param url:
        :param params:
        :return:
        '''
        url = url + "/courseApi/api/v1/course/statistics/version"
        r = requests.get(url=url, headers=headers, params=params)
        return r

    @classmethod
    def totalnumber(cls, url: str, params=None, pathparams=None,headers=headers_web):
        '''
        @Summary:课程教学数据选课人数及开班数量统计
        @Description:1.云课堂老师端-课程教学数据统计使用
        :param url:
        :param params:
        :param pathparams:；路径参数
        :return:
        '''
        url = url + f"/courseApi/api/v1/course/{pathparams}/totalnumber"
        r = requests.get(url=url, headers=headers, params=params)
        return r

    @classmethod
    def count_statistics(cls, url: str, params=None,headers=headers_web):
        '''
        @Summary:根据学年学期和课程类型统计学期开课的课程数
        :param url:
        :param params:
        :return:
        '''
        url = url + "/courseApi/api/v1/courseCountstatistics"
        r = requests.get(url=url, headers=headers, params=params)
        return r

    @classmethod
    def coursebuild_statistics(cls, url: str, params=None,headers=headers_web):
        '''
        @Summary:课程建设完成情况统计接口
        @Description:大数据平台-课程建设完成情况使用
        :param url:
        :param params:
        :return:
        '''
        url = url + "/courseApi/api/v1/coursebuild/statistics"
        r = requests.get(url=url, headers=headers, params=params)
        return r

    @classmethod
    def courseresource_statistics(cls, url: str, params=None,headers=headers_web):
        '''
        @Summary:课程资源统计信息
        @Description:大数据平台-资源总数统计使用
        :param url:
        :param params:
        :return:
        '''
        url = url + "/courseApi/api/v1/courseresource/statistics"
        r = requests.get(url=url, headers=headers, params=params)
        return r

    @classmethod
    def coursestatistics(cls, url: str, params=None,headers=headers_web):
        '''
        @Summary:课程信息统计
        @Description:1.大数据平台-整体数据使用；2.大数据平台-课程画像使用
        :param url:
        :param params:
        :return:
        '''
        url = url + "/courseApi/api/v1/courseresource/statistics"
        r = requests.get(url=url, headers=headers, params=params)
        return r


if __name__ == '__main__':
    resp = CourseStatistics.statistics_knowledge(url=url, params={
    "courseId": "1122108",
    "validCode": "155cc6439a2bd898c289a0a86ee1058c",
    "versionId": "2"
    })
    # from common.hashlib_utils import hash_md5
    #
    # valid_code = hash_md5("courseId=" + "1122108" + "&signKey=123123")
    # resp = CourseStatistics.totalnumber(url, params={
    #     "schoolYear": "2022-2023",
    #     "term": "2",
    #     "validCode": valid_code
    # }, pathparams="1122108")
    print(resp.url, "\n", resp, resp.content)
    print(resp.request.headers, "\n", resp.request.method)
